package com.yy.blogdemo.config;


import com.yy.blogdemo.interceptor.Corsinterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 拦截器配置
 * public api/v1/pub/
 * private api/v1/pri
 *
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

//    @Bean
//    LoginInterceptor loginInterceptor(){
//        return new LoginInterceptor();
//    }/////
//
    @Bean
    Corsinterceptor corsinterceptor(){
        return new Corsinterceptor();
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截全部路径，这个跨域要放在最上面
        registry.addInterceptor(corsinterceptor()).addPathPatterns("/**");

//        registry.addInterceptor(loginInterceptor()).addPathPatterns("/api/v1/pri/*/*/**")
//                .excludePathPatterns("/api/v1/pri/user/login","/api/v1/pri/user/register");
//        WebMvcConfigurer.super.addInterceptors(registry);

    }
}
